package com.bsit.obu.fragment;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bsit.obu.R;
import com.bsit.obu.model.CarSecondPublicInfo;
import com.bsit.obu.model.car.CarType;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CarFragment extends Fragment {
    @BindView(R.id.et_palteNo)
    EditText et_palteNo;

    @BindView(R.id.tv_plateColor)
    TextView tv_plateColor;

    @BindView(R.id.tv_plateModel)
    TextView tv_plateModel;


    @BindView(R.id.tv_userType)
    TextView tv_userType;
    @BindView(R.id.et_traction_mass)
    EditText et_traction_mass;//核定载质量/准牵引总质量(kg)

    @BindView(R.id.et_curb_weight)
    EditText et_curb_weight;

    @BindView(R.id.et_passager_capacity)
    EditText et_passager_capacity;

    @BindView(R.id.total_weight)
    EditText total_weight;


    @BindView(R.id.et_car_len)
    EditText et_car_len;

    @BindView(R.id.et_car_wid)
    EditText et_car_wid;

    @BindView(R.id.et_car_height)
    EditText et_car_height;

    @BindView(R.id.et_engine_no)
    EditText et_engine_no;


    @BindView(R.id.et_car_descr)
    EditText et_car_descr;


    @BindView(R.id.cheliang_size_ll)
    LinearLayout cheliang_size_ll;
    @BindView(R.id.cheliang_all_quality_ll)
    LinearLayout cheliang_all_quality_ll;
    @BindView(R.id.zhengbei_quality_ll)
    LinearLayout zhengbei_quality_ll;
    @BindView(R.id.heding_quality_ll)
    LinearLayout heding_quality_ll;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View  mView = inflater.inflate(R.layout.fragment_car, null);
        ButterKnife.bind(this, mView);
        return mView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }
    public void updateUI(CarSecondPublicInfo carSecondPublicInfo){
        et_palteNo.setText(carSecondPublicInfo.getPalteNo()); //车牌号
        tv_plateColor.setText(carSecondPublicInfo.getPlateColor()); //车牌颜色
        tv_plateModel.setText(CarType.getContent(carSecondPublicInfo.getCarType())); //车型
        tv_userType.setText(carSecondPublicInfo.getUserType()); //用户类别
        if(carSecondPublicInfo.getCarType()>6){
            cheliang_size_ll.setVisibility(View.VISIBLE);
            cheliang_all_quality_ll.setVisibility(View.VISIBLE);
            zhengbei_quality_ll.setVisibility(View.VISIBLE);
            heding_quality_ll.setVisibility(View.VISIBLE);
            et_curb_weight.setText(carSecondPublicInfo.getCurbWeight()+"");
            et_traction_mass.setText(carSecondPublicInfo.getTractionMass()+"");
            total_weight.setText(carSecondPublicInfo.getTotalMass()+"");
            String[] strArr = carSecondPublicInfo.getPlataSize().split("\\*");
            et_car_len.setText(strArr[0]);
            et_car_wid.setText(strArr[1]);
            et_car_height.setText(strArr[2]);
            et_passager_capacity.setText(carSecondPublicInfo.getPassagerCapacity()+"");
        }else{
            cheliang_size_ll.setVisibility(View.GONE);
            cheliang_all_quality_ll.setVisibility(View.GONE);
            zhengbei_quality_ll.setVisibility(View.GONE);
            heding_quality_ll.setVisibility(View.GONE);
        }


        et_engine_no.setText(carSecondPublicInfo.getEngineNo());
      //  et_car_descr.setText(carSecondPublicInfo.getMessageCode());


    }
}
